﻿using System.Text.RegularExpressions;

namespace LdtDataEngin.ModuleDetail.CommonModule.LawDeduce
{
    /// <summary>
    /// 法律发条内容格式化
    /// </summary>
    public class QutoLawFormat
    {
        /// <summary>
        /// 针对添加引用的法规进行文本内容格式化
        /// Qutoes the law text format.
        /// </summary>
        /// <param name="lawstr">The lawstr.</param>
        /// <returns></returns>
        public static string QutoLawTextFormat(string lawstr)
        {
            #region 判断内容开始和结束位置是否存在“《”进行替换


            if (lawstr.IndexOf("《") == 0 && lawstr.LastIndexOf("》") == lawstr.Length - 1)
            {//如果法规的内容前后为《》，则进行替换掉；
                lawstr = Regex.Replace(lawstr, "《|》", "");
            }


            #endregion

            #region 格式化文本中存在“<”的内容

            lawstr = Regex.Replace(lawstr, "<|＜|<|＜|﹤|〈|〈〈", "《");
            lawstr = Regex.Replace(lawstr, ">|＞|›|〉|﹥|＞|〉〉", "》");

            #endregion

            return lawstr;
        }


    }
}
